import Vue from 'vue';
import Vuex from 'vuex';
import a from './modules/a';
import b from './modules/b';
Vue.use(Vuex);

export interface State {
  name: string;
  age: number;
  high: string;
  inters: object[];
}

const stateVal: State = {
  name: 'zhansgan',
  age: 12,
  high: '221cm',
  inters: [
    {
      name: '篮球1',
      level: 12,
    },
    {
      name: '篮球2',
      level: 21,
    },
    {
      name: '篮球3',
      level: 44,
    },
  ],
};

export default new Vuex.Store({
  state: {
    ...stateVal,
  },
  mutations: {
    setVal(state, name): void {
      state.name = name;
    },
  },
  getters: {
    name(state) {
      return state.name;
    },
    inters(state) {
      return state.inters;
    },
  },
  actions: {},
  modules: {
    a,
    b,
  },
});
